package com.macro.mall.portal.sms;

import com.macro.mall.model.SmsMessageHistory;
import com.macro.mall.portal.service.SmsMessageHistoryService;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import lombok.Data;

/**
 * 统一短信接口
 *
 * @author 郎
 */
@Data
public class SmsMessageService {
    private String active;
    private SmsMessage message;
    private SmsMessageHistoryService smsMessageHistoryService;

    public Boolean sendMessage(String phone, String verifyCode) throws TencentCloudSDKException {
        SmsMessageHistory smsMessageHistory = message.sendMessage(phone, verifyCode);
        Boolean save = smsMessageHistoryService.save(smsMessageHistory);
        return save && smsMessageHistory.getStatus() == 1;
    }

    public Object getResponseStatus() {
        return null;
    }

    public Long getExpireTimeSecond() {
        return message.getExpireTimeSecond();
    }
}
